/*
 * HashTableChain.h
 *
 *  Created on: Sep 15, 2012
 *      Author: jeffrey
 */

#ifndef HASHTABLECHAIN_H_
#define HASHTABLECHAIN_H_
#include<iostream>
#include<string>
#include<list>
#include<vector>
#include<utility>
#include<limits>
using namespace std;
namespace structure {

class HashTableChain {
public:
	HashTableChain(int size);
	virtual ~HashTableChain();
	static int hash(string key) {
		int mod = 100001;
		int total = 0;
		for (int i = 0; i < key.length(); i++) {
			total *= 256;
			total += (int) key[i];
			total %= mod;
		}
		return total;
	}
	void put(string key, int v);
	int get(string key);
private:
	vector<list<pair<string, int> > > entry;
};
class OpenAddress {
public:
	OpenAddress(int size);
	static int hash(string key) {
		return 0;
	}
	int probe(int pos){
		return (pos+1)%entry.size();
	}
	void put(string key, int v);
	int get(string key);
private:
	vector<pair<string,int > > entry;
};

} /* namespace structure */
#endif /* HASHTABLECHAIN_H_ */
